<?php
namespace Admin\Controller;
use Think\Controller;
class LoginController extends Controller {
    // 登录页面
    public function index(){
    	layout(false);
        $this->display();
    }
    // 登录
    public function login(){
        $data['account']=I('post.account');
        $data['password']=I('post.password');
        $administrator=M('administrator');
        $res=$administrator->where($data)->find();
        if(!empty($res)){
           cookie('tianjiao_account_id',$res["id"],3600);
    	   cookie('tianjiao_account_name',$res["name"],3600);
           $this->success("登录成功",U("Index/index"),1);
        }else{
            $this->error("用户名或者密码错误",U("Login/index"),1);
        }
    }
    // 退出
    public function logout(){
        cookie('account_id',null);
        cookie('account_name',null);
    	$this->redirect('Login/index');
    }
}